
var pagedata = {
    scanVisible:false,
    scanImgSrc:'',
    //表格
    tableData: [],
    searchFormData:{
        pageSize: 30,//默认每页数据量
        currentPage: 1,//当前页码
        start: 1,//查询的页码
        totalCount: 0,//默认数据总数
        sort:"",//排序字段
        order:""//排序方式
    },
}

var app = new Vue({
    el:"#app",
    data:pagedata,
    methods:{
        handleSizeChange:function(val) {
            pagedata.searchFormData.pageSize = val;
            searchSubmit();
        },
        handleCurrentChange:function(val) {
            pagedata.searchFormData.currentPage = val;
            searchSubmit();
        },
        handleScanClick(row) {
            $.ajax({
                type: 'post',
                url: BASE+'/api/dev/createScanImg',
                dataType: 'json',
                async: true,
                data: {"userId":row.stUserId,"devId":row.stDevId},
                success: function(resdata) {
                    if(resdata.code=="1000"){
                        pagedata.scanImgSrc = BASE+"/static/images/qrcode.jpg?"+Date.parse(new Date());
                        pagedata.scanVisible = true;
                    }
                    else{
                        alert(resdata.msg);
                    }
                },
                error: function(error) {
                    console.log(error);
                },
            });

        }
    },
});

$(function () {
    searchSubmit();
});

function searchSubmit(){
    $.ajax({
        type: 'post',
        url: BASE+'/dev/findAllUserDevs',
        dataType: 'json',
        async: true,
        data: pagedata.searchFormData,
        success: function(res) {
            //有数据 需要显示
            pagedata.tableData = res.data.list;
        },
        error: function(error) {
            console.log(error);
        },
    });
}